package com.itheima.controller;


import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.service.DubboService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/dubbo")
public class DubboController {
    @Reference(loadbalance = "random")
    //查找名字为刚才接口名字的服务  负载均衡默认是RandomLoadBalance RoundRobinLoadBalance:轮询负载均衡。轮询选择一个。
    private DubboService dubboService;

    @RequestMapping(value = "/getName", produces = "text/html;charset=utf-8")
    @ResponseBody
    public String getName(String name) {
        String username = dubboService.save(name);
        return "名字是" + username;
    }
}
